--[[---------------------------------------------------------

  Vortex Command



---------------------------------------------------------]]--
include( 'shared.lua' )

/*-----------------------------------
	Camera
-----------------------------------*/
--server messages
function GM.SetPlayerObject(um)
	 local ent = um:ReadEntity()
	 
	 GAMEMODE.LocalEntity = ent
	 
	 gui.EnableScreenClicker(true)
end

usermessage.Hook("vc_AssignPlayerEntity",GM.SetPlayerObject)

--this should work, lawl
function GM:CalcView( ply, origin, angles, fov )
	 if not ValidEntity(GAMEMODE.LocalEntity) then return false end --No override, I believe

	 local vec = LocalPlayer():GetAimVector()
	 local campos = LocalEntity:GetPos() + (vec * -500)
	 local view = {}
	 view.origin = campos
	 view.angles = LocalPlayer():EyeAngles() -- This the angle anyhow, have fun :D
	 view.fov = fov --no override for now

	 return view
end

/*-----------------------------------
	Cursor
-----------------------------------*/
function GM:HUDPaint()
	 self:DrawCrosshair()
end

--sprites/laserdot
function GM:DrawCrosshair() -- fancy '3D' crosshair, thought I'd try
	 local x,y = gui.MousePos()
	 local vec = gui.ScreenToVector(x,y)
	 local spos = LocalPlayer():GetShootPos()
	 
	 local trace = {}
	 trace.start = spos
	 trace.endpos = spos + (vec * 99999) // A bit much, no? :S err, yeah but it's sposed to be infinite, it just means it will go as far as needed
	 trace.filter = {LocalPlayer(),LocalEntity}
	 
	 local tr = util.TraceLine(trace)
	 
	 render.SetMaterial( Material( "sprites/laserdot" ) ) 
   	 render.DrawSprite( tr.HitPos, 6, 6, Color(255, 255, 255, 255) )  
end

